Skip to content

Conversation

@tcdent
Copy link
Owner

@tcdent tcdent commented Jan 24, 2026

Inject external events (user messages, file changes, background tasks) into agent context mid-turn.

Approach

Tool Result Augmentation - append <notification> XML to tool results (same pattern as Claude Code's <system-reminder>).

Completed

  • NotificationSource enum and Notification struct with to_xml()
  • is_ephemeral() method on Block trait
  • NotificationBlock - rendered but not persisted to transcript
  • Custom Serialize for Turn that filters ephemeral blocks
  • Design doc with decisions: research/notifications-primitive.md

Remaining

  • Add notification queue to App struct
  • Wire queue_message() to create notifications when streaming
  • Wire ToolEvent::Completed to drain and inject notifications
  • System prompt explaining <notification> tags
  • Tests

Explores a new primitive for injecting external events into agent context:
- Notification structure and types (source, priority, content)
- Transcript integration via NotificationBlock
- Multiple activation modes (passive, prompt, active)
- Mid-stream injection points analysis
- Priority-based injection strategies
- State machine for turn interruption
Explores using synthetic tool calls to inject notifications mid-turn,
leveraging existing tool infrastructure. Key insight: notifications
can be injected between tool calls without agent explicitly checking.
Based on observation of Claude Code's <system-reminder> pattern:
- Approach A (recommended): Append notifications to tool results with XML
- Approach B (alternative): Synthetic tool call injection

Key insight: tool results are unstructured text, so we can append
notification content directly with XML delimiters. No fake tool calls
needed - same call_id, just richer content.
Streamlined to focus on key findings:
- Tool results are unstructured text (key insight)
- Approach A: Append to tool results with XML (recommended, proven in Claude Code)
- Approach B: Synthetic tool injection (alternative)
- Comparison and recommendation

Removed verbose sections on priorities, activation modes, state machines.
Documents options for when notifications pile up:
- Append all (simple but unbounded)
- Batch into single block (compact)
- Coalesce by source (reduces noise)
- Cap with overflow indicator (bounds tokens)

Recommends combining: coalesce + batch + cap + prioritize.
- Tool Result Augmentation approach (proven pattern from Claude Code)
- Unified notification flow based on agent state
- Simplifications: no count, no cap, no coalescing (defer)
- Ephemeral NotificationBlock for display only (not persisted)
- Add NotificationSource enum and Notification struct with to_xml()
- Add is_ephemeral() method to Block trait
- Add NotificationBlock for rendering notifications (ephemeral)
- Custom Serialize for Turn filters out ephemeral blocks
- Update research doc with implementation progress

Remaining: wiring queue_message() and ToolEvent::Completed handler
@tcdent tcdent changed the title research: Add notifications primitive design document feat: notifications primitive Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants